<template>
  <el-form
    label-width="100px"
    class="container"
  >
    <el-form-item label="邮箱" >
      <el-input
        type="password"
        v-model="password"
        placeholder="Enter password..."
      ></el-input>
    </el-form-item>
    <el-form-item>
      <el-button
        @click="resetPasswork()"
        type="primary"
        class="submit-btn"
        >找回密码</el-button
      >
    </el-form-item>
  </el-form>
</template>

<script lang="ts">
import {ref, getCurrentInstance } from "vue";
import { useRouter,useRoute } from "vue-router";
export default {

  setup() {
    console.log(getCurrentInstance());
    
    // @ts-ignore
    const { ctx } = getCurrentInstance();
    //路由传参
    const  route  = useRoute() 
    //路由跳转
    const  router = useRouter() 
    const password = ref<string>("")
    const  resetPasswork = async () =>{
      if(password.value){
        const res =  await ctx.$axios.put(
          'api/v1/auth/resetpassword/'+ route.params.id,
          {
            password:password.value
          }
        )
        if(res.data.success){
          router.push('/')
        }
      }
    }
    return { resetPasswork,password };
  },
};
</script>
<style scoped>
.container{
  width: 50%;
  margin: 200px auto;
}
.submit-btn {
  width: 100%;
}
.tiparea {
  text-align: right;
  font-size: 12px;
  color: #333;
}
.tiparea p a {
  color: #409eff;
}
</style>